package com.algorithm.hqy;

/**
 * @Classname ListTest
 * @Date 2019/9/17 14:41
 * @auther by hqy
 */
public class ListTest {

    public static void main(String[] args) {
/*        SingleLinkedList singleLinkedList = new SingleLinkedList<NodeImple>();
        singleLinkedList.addSorted(new NodeImple(1));
        singleLinkedList.addSorted(new NodeImple(2));
        singleLinkedList.addSorted(new NodeImple(3));
        singleLinkedList.addSorted(new NodeImple(-1));
        singleLinkedList.reverseList();
        singleLinkedList.show();
        singleLinkedList.deleteNode(new NodeImple(1));
        singleLinkedList.show();*/

        DoubleLinkedList doubleLinkedList=new DoubleLinkedList<DoubleNodeTemple>();
        doubleLinkedList.addSort(new DoubleNodeTemple(1));
        doubleLinkedList.addSort(new DoubleNodeTemple(2));
        doubleLinkedList.addSort(new DoubleNodeTemple(3));
        doubleLinkedList.addSort(new DoubleNodeTemple(-1));
        doubleLinkedList.show();
        doubleLinkedList.delNode(new DoubleNodeTemple(1));
        doubleLinkedList.show();
        System.out.println(doubleLinkedList.getIndex(1));
        doubleLinkedList.reverse();
        doubleLinkedList.show();
    }


}

class DoubleNodeTemple extends DoubleLinkedNode<DoubleNodeTemple> {
    private int no;

    public DoubleNodeTemple(int no) {
        this.no = no;
    }


    @Override
    public int compare(DoubleNodeTemple doubleNodeTemple) {
        return this.no - doubleNodeTemple.no;
    }

    @Override
    public String toString() {
        return this.getClass().getName() + ":" + this.no;
    }
}


class NodeImple extends Node<NodeImple> {
    private int no;

    public NodeImple(int no) {
        this.no = no;
    }

    @Override
    public int compareTo(NodeImple comparator) {
        return this.no - comparator.no;
    }

    @Override
    public String toString() {
        return this.getClass().getName() + ":" + this.no;
    }
}
